<?php

namespace app\agent\validate;

use think\Validate;

class Config extends Validate
{
    protected $rule = [
        // 公众号配置
        'app_id' => 'require|max:32',
        'app_secret' => 'require|max:32',
        'token' => 'max:32',
        'aes_key' => 'max:43',

        // 小程序配置
        'mini_app_id' => 'require|max:32',
        'mini_app_secret' => 'require|max:32',
        'qq_map_key' => 'require|max:',
 
        // 微信支付配置
        'mch_id' => 'require|max:32',
        'mch_key' => 'require|max:32',
        // 'cert_path' => 'max:100',
        // 'key_path' => 'max:100',

        // 支付宝配置
        'ali_app_id' => 'require|max:32',
        'ali_public_key' => 'require',
        'ali_private_key' => 'require',

        // 提现设置
        'withdraw_charge' => 'require|number|egt:0|elt:10',
        'withdraw_min_amount' => 'require|egt:0|elt:100',
        'withdraw_daily_times' => 'require|number|egt:0|elt:100',

        //客服链接配置
        'customer_service_url' =>['require', 'regex' => '/^https/'],
    ];

    protected $message = [
        'app_id.require' => '请输入 AppID',
        'app_id.max' => 'AppID 不能超过 32 个字符',
        'app_secret.require' => '请输入 AppSecret',
        'app_secret.max' => 'AppSecret 不能超过 32 个字符',
        'token.max' => '令牌 Token 不能超过 32 个字符',
        'aes_key.max' => 'AesKey 不能超过 43 个字符',

        'mini_app_id.require' => '请输入 AppID',
        'mini_app_id.max' => 'AppID 不能超过 32 个字符',
        'mini_app_secret.require' => '请输入 AppSecret',
        'mini_app_secret.max' => 'AppSecret 不能超过 32 个字符',

        'mch_id.require' => '请输入商户号',
        'mch_id.max' => '商户号不能超过 32 个字符',
        'mch_key.require' => '请输入商户密钥',
        'mch_key.max' => '商户密钥不能超过 32 个字符',

        'ali_app_id.require' => '请输入 AppID',
        'ali_app_id.max' => 'AppID 不能超过 32 个字符',
        'ali_public_key.require' => '请输入支付宝公钥',
        'ali_private_key.max' => '请输入应用密钥',

        'withdraw_charge.require' => '请输入提现手续费',
        'withdraw_charge.number' => '提现手续费只能是整数',
        'withdraw_charge.egt' => '提现手续费不能小于 0',
        'withdraw_charge.elt' => '提现手续费不能大于 10',
        'withdraw_min_amount.require' => '请输入最低提现金额',
        'withdraw_min_amount.egt' => '最低提现金额不能小于 0',
        'withdraw_min_amount.elt' => '最低提现金额不能大于 100',
        'withdraw_daily_times.require' => '请输入每天提现次数',
        'withdraw_daily_times.number' => '每天提现次数只能是整数',
        'withdraw_daily_times.egt' => '每天提现次数不能小于 0',
        'withdraw_daily_times.elt' => '每天提现次数不能大于 100',

        'customer_service_url.require'=>'客服系统链接不能为空！',
        'customer_service_url.regex'=>'客服系统链接只支持https格式！'
    ];

    protected $scene = [
        'official' => [
            'app_id',
            'app_secret',
            'token',
            'aes_key',
        ],
        'wxpay' => [
            'mch_id',
            'mch_key',
        ],
        'miniprogram' => [
            'mini_app_id',
            'mini_app_secret',
        ],
        'alipay' => [
            'ali_app_id',
            'ali_public_key',
            'ali_private_key',
        ],
        'withdraw' => [
            'withdraw_charge',
            'withdraw_min_amount',
            'withdraw_daily_times',
        ],
        'customer_service'=>[
             'customer_service_url'
        ]
    ];
}
